package kyssion.leetcode.num151_200;

public class code189_旋转数组 {


    public static void main(String[] args) {
        int[] arrs = new int[]{
                1
        };
        new code189_旋转数组().rotate(arrs, 1000);
        System.out.println();
    }

    public void rotate(int[] nums, int k) {
        if (k == 0 || nums.length == 0) {
            return;
        }
        if (k > nums.length) {
            k = k % nums.length;
        }
        resert(nums, 0, nums.length - 1);
        resert(nums, 0, k - 1);
        resert(nums, k, nums.length - 1);
    }

    public void resert(int[] arr, int start, int end) {
        int midle = (start + end) / 2;
        int left = start;
        int right = end;
        int item;
        while (left <= midle) {
            item = arr[left];
            arr[left] = arr[right];
            arr[right] = item;
            left++;
            right--;
        }
    }
}
